home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / John Silver (RU).ifs < prev    next >
Text File  |  2005-03-28  |  11KB  |  284 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=Karamov Ilshat aka KAA (kaa2@pisem.net)
  8. Title=John Silver (RU)
  9. Description=Import from www.kino.orc.ru
  10. Site=www.kino.orc.ru
  11. Language=RU
  12. Version=1.1
  13. Requires=3.5.0
  14. Comments=─ε±≥≤∩ Ω ≡σ÷σφτΦ ∞ ─µεφα ╤ΦδⁿΓσ≡α, ≡ατ∞σ∙σφφ√⌡ φα ±αΘ≥σ www.kino.orc.ru
  15. License=This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
  16. GetInfo=1
  17.  
  18. [Options]
  19.  
  20. ***************************************************)
  21.  
  22. program John_Silver;
  23.  
  24. const
  25.   BaseAddress = 'http://www.kino.orc.ru/js/review/';
  26.  
  27. var
  28.   MovieName: string;
  29.  
  30. //==============================================================================
  31.   procedure AnalyzePage();
  32.   var
  33.     Page: TStringList;
  34.     BeginPos, EndPos: Integer;
  35.     AddressText, HTMLText : string;
  36.   begin
  37.   Page := TStringList.Create;
  38.  
  39.   PickTreeClear;
  40.   PickTreeAdd('╨σ÷σφτΦΦ ─µεφα ╤ΦδⁿΓσ≡α φα ⌠Φδⁿ∞√ Γ αδ⌠αΓΦ≥φε∞ ∩ε≡ ΣΩσ', '');
  41.   AddAlphabet();
  42.   if PickTreeExec(AddressText) then
  43.   begin
  44.     Page.Text := GetPage(AddressText);
  45.     HTMLText := Page.Text;
  46.   end;
  47.   if Pos('<center><table bgcolor="#000000"  cellspacing="1" width="730">', HTMLText) <> 0 then
  48.   begin
  49.     BeginPos := Pos('<center><table bgcolor="#000000"  cellspacing="1" width="730">', HTMLText);
  50.     HTMLText := Copy(HTMLText, BeginPos+Length('<center><table bgcolor="#000000"  cellspacing="1" width="730">'), Length(HTMLText));
  51.     BeginPos := Pos('</td></tr>', HTMLText);
  52.     HTMLText := Copy(HTMLText, BeginPos+Length('</td></tr>'), Length(HTMLText));
  53.     EndPos :=  Pos('<tr><td align', HTMLText);
  54.     HTMLText := Copy(HTMLText, 0, EndPos-1);
  55.     Page.Text:=Trim(HTMLText);
  56.     PickTreeClear;
  57.     PickTreeAdd('╘Φδⁿ∞√ φα Γ√ß≡αφφ≤■ ß≤ΩΓ≤', '');
  58.     AddMoviesTitles(Page);
  59.     if PickTreeExec(AddressText) then
  60.     begin
  61.        // URL
  62.        if CanSetField(fieldURL) then
  63.          SetField(fieldURL, AddressText);
  64.        Page.Text := GetPage(AddressText);
  65.        AnalyzeVideoPage(Page);
  66.     end;
  67.   end;
  68.   Page.Free;
  69. end;
  70.  
  71. //==============================================================================
  72.   procedure AddMoviesTitles(Page: TStringList);
  73.   var
  74.     i: integer;
  75.     Line: string;
  76.     MovieTitle, MovieAddress: string;
  77.     StartPos, EndPos: Integer;
  78.   begin
  79.     for  i:=0  to Page.Count-1 do
  80.     begin
  81.       Line := Page.GetString(i);
  82.       if Line='' then
  83.         Continue;
  84.       StartPos := Pos('<a href="', Line);
  85.       Line := Copy(Line, StartPos+Length('<a href="'), Length(Line));
  86.       EndPos := Pos('">', Line);
  87.       MovieAddress := BaseAddress+Copy(Line, 0, EndPos-1);
  88.       StartPos := Pos('">', Line);
  89.       Line := Copy(Line, StartPos+Length('">'), Length(Line));
  90.       StartPos := Pos('">', Line);
  91.       EndPos := Pos('</a>', Line);
  92.       MovieTitle := Copy(Line, StartPos+Length('">'), EndPos-1);
  93.       HTMLRemoveTags(MovieTitle);
  94.       PickTreeAdd(MovieTitle, MovieAddress);
  95.     end;
  96.   end;
  97.  
  98. //==============================================================================
  99.   procedure AddAlphabet();
  100.   var
  101.     i: integer;
  102.     Alphabet, Addresses, MovieTitle, MovieAddress: string;
  103.     StartPos, EndPos: Integer;
  104.   begin
  105.     Alphabet :='└ ┴ ┬ ├ ─ ┼ ╞ ╟ ╚ ╩ ╦ ╠ ═ ╬ ╧ ╨ ╤ ╥ ╙ ╘ ╒ ╓ ╫ ╪ ┘ ▌ ▐ ▀ 1-10 ';
  106.     Addresses:='a b v g d ye zh z i k l m n o p r s t u f h ts ch sh shch e yu ya 110 ';
  107.     StartPos:=1;
  108.     for  i:=1  to 29 do
  109.     begin
  110.       EndPos:=Pos(' ', Alphabet);
  111.       MovieTitle := Copy(Alphabet, 1, EndPos);
  112.       Alphabet:=Copy(Alphabet, EndPos+1, Length(Alphabet));
  113.     
  114.       EndPos:=Pos(' ', Addresses);
  115.       MovieAddress := Copy(Addresses, 1, EndPos-1);
  116.       Addresses:=Copy(Addresses, EndPos+1, Length(Addresses));
  117.       
  118.       PickTreeAdd(MovieTitle, BaseAddress+MovieAddress+'.shtml');
  119.     end;
  120.   end;
  121.  
  122. //==============================================================================
  123.   procedure AnalyzeVideoPage(Page: TStringList);
  124.   var
  125.     HTMLText, HTMLText1: string;
  126.     BeginPos, EndPos: Integer;
  127.     MovieName, MovieNameTrans, MovieNameOrig, MovieDirector,
  128.                MovieYear, MovieCategory, MovieRating,
  129.                MoviePictureAddress, MovieLength, MovieCountry,
  130.                MovieActors, MovieComments: string;
  131.   begin
  132.  
  133.   HTMLText:=Page.Text;
  134.   HTMLText:=StringReplace(HTMLText, #13#10+'                      ', ' ');
  135.   HTMLText:=StringReplace(HTMLText, #13#10+'        ', ' ');
  136.   HTMLText:=StringReplace(HTMLText, #13#10+'  ', ' ');
  137.   HTMLText:=StringReplace(HTMLText, '"', '"');
  138.   HTMLText:=StringReplace(HTMLText, ' ', ' ');
  139.  
  140.   BeginPos := Pos('<p ALIGN="center"><b>', HTMLText)+Length('<p ALIGN="center"><b>');
  141.   HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText));
  142.   // ═αΦ∞σφεΓαφΦσ
  143.   if CanSetField(fieldTranslatedTitle) then
  144.     begin
  145.       if Pos('polosa_title.jpg', HTMLText)<>0 then
  146.         begin
  147.           BeginPos := Pos('polosa_title.jpg', HTMLText)+Length('polosa_title.jpg');
  148.           HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText));
  149.           BeginPos := Pos('<b>', HTMLText)+Length('<b>');
  150.           HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText));
  151.           EndPos := Pos('</b>', HTMLText);
  152.  
  153.           MovieNameTrans := Trim(Copy(HTMLText, 0, EndPos-1));
  154.           EndPos := Pos(' (', HTMLText);
  155.           MovieNameOrig := Trim(Copy(MovieNameTrans, EndPos+2, Length(MovieNameTrans)));
  156.           MovieNameTrans := Trim(Copy(MovieNameTrans, 0, EndPos-1));
  157.           EndPos := Pos(')', MovieNameTrans);
  158.           MovieNameOrig := Trim(Copy(MovieNameOrig, 0, EndPos-1));
  159.           SetField(fieldTranslatedTitle, MovieNameTrans);
  160.         end;
  161.     end;
  162.   // ╬≡ΦπΦφαδⁿφεσ φαΦ∞σφεΓαφΦσ
  163.   if CanSetField(fieldOriginalTitle) then
  164.     begin
  165.       SetField(fieldOriginalTitle, MovieNameOrig);
  166.     end;
  167.   BeginPos := Pos('polosa_title.jpg', HTMLText)+Length('polosa_title.jpg');
  168.   HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText));
  169.   // └Σ≡σ± Ωα≡≥ΦφΩΦ
  170.   BeginPos := Pos('<img src="', HTMLText)+Length('<img src="');
  171.   EndPos := Pos('" border', HTMLText);
  172.   MoviePictureAddress := BaseAddress+Trim(Copy(HTMLText, BeginPos, EndPos-BeginPos));
  173.   // ╨σµΦ±±σ≡√
  174.   if CanSetField(fieldDirector) then
  175.     begin
  176.       if Pos('╨σµΦ±±σ≡', HTMLText)<>0 then
  177.         begin
  178.           BeginPos := Pos('╨σµΦ±±σ≡', HTMLText)+Length('╨σµΦ±±σ≡');
  179.           HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText));
  180.           BeginPos := Pos('">', HTMLText)+Length('">');
  181.           EndPos := Pos('</p>', HTMLText);
  182.           MovieDirector := Trim(Copy(HTMLText, BeginPos, EndPos-BeginPos));
  183.           HTMLRemoveTags(MovieDirector);
  184.           MovieDirector:=Trim(StringReplace(MovieDirector, '-', ''));
  185.           SetField(fieldDirector, MovieDirector);
  186.         end
  187.     end;
  188.   BeginPos := Pos('</p>', HTMLText)+Length('</p>');
  189.   HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText));
  190.   // └Ω≥σ≡√
  191.   if CanSetField(fieldActors) then
  192.     begin
  193.       if Pos('┬ ≡εδ ⌡', HTMLText)<>0 then
  194.         begin
  195.           BeginPos := Pos('┬ ≡εδ ⌡', HTMLText)+Length('┬ ≡εδ ⌡');
  196.           HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText));
  197.           BeginPos := Pos('">', HTMLText)+Length('">');
  198.           EndPos := Pos('</p>', HTMLText);
  199.           MovieActors := Trim(Copy(HTMLText, BeginPos, EndPos-BeginPos));
  200.           HTMLRemoveTags(MovieActors);
  201.           MovieActors:=Trim(StringReplace(MovieActors, '-', ''));
  202.           SetField(fieldActors, MovieActors);
  203.        end;
  204.     end;
  205.   BeginPos := Pos('</p>', HTMLText)+Length('</p>');
  206.   HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText));
  207.   // ╧≡εΣεδµΦ≥σδⁿφε±≥ⁿ
  208.   if CanSetField(fieldLength) then
  209.     begin
  210.       if Pos('╧≡εΣεδµΦ≥σδⁿφε±≥ⁿ', HTMLText)<>0 then
  211.         begin
  212.           BeginPos := Pos('╧≡εΣεδµΦ≥σδⁿφε±≥ⁿ', HTMLText)+Length('╧≡εΣεδµΦ≥σδⁿφε±≥ⁿ');
  213.           HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText));
  214.           BeginPos := Pos('">', HTMLText)+Length('">');
  215.           EndPos := Pos(' ∞Φφ≤≥', HTMLText);
  216.           MovieLength := Trim(Copy(HTMLText, BeginPos, EndPos-BeginPos));
  217.           SetField(fieldLength, MovieLength);
  218.         end;
  219.     end;
  220.   BeginPos := Pos(' ∞Φφ≤≥', HTMLText)+Length(' ∞Φφ≤≥');
  221.   HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText));
  222.   // ├εΣ
  223.   if CanSetField(fieldYear) then
  224.     begin
  225.       if Pos('├εΣ Γ√∩≤±Ωα', HTMLText)<>0 then
  226.         begin
  227.           BeginPos := Pos('├εΣ Γ√∩≤±Ωα', HTMLText)+Length('├εΣ Γ√∩≤±Ωα');
  228.           HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText));
  229.           BeginPos := Pos('">', HTMLText)+Length('">');
  230.           EndPos := Pos('</p>', HTMLText);
  231.           MovieYear := Trim(Copy(HTMLText, BeginPos, EndPos-BeginPos));
  232.           SetField(fieldYear, MovieYear);
  233.         end;
  234.     end;
  235.   BeginPos := Pos('</p>', HTMLText)+Length('</p>');
  236.   HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText));
  237.   // ╨σΘ≥Φφπ
  238.   if CanSetField(fieldRating) then
  239.      begin
  240.       if Pos('╬ß∙α  - ', HTMLText)<>0 then
  241.         begin
  242.           BeginPos := Pos('╬ß∙α  - ', HTMLText)+Length('╬ß∙α  - ');
  243.           HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText));
  244.           EndPos := Pos('<br>', HTMLText);
  245.           MovieRating := Trim(Copy(HTMLText, 0, EndPos-1));
  246.           SetField(fieldRating, MovieRating);
  247.         end;
  248.     end;
  249.   BeginPos := Pos('<br>', HTMLText)+Length('<br>');
  250.   HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText));
  251.   // ╩ε∞σφ≥α≡ΦΘ-ε≥τ√Γ
  252.   if CanSetField(fieldComments) then
  253.     begin
  254.       BeginPos := Pos('<p align="justify"  style="text-indent: 30; margin-left: 6; margin-right: 6">', HTMLText)
  255.       +Length('<p align="justify"  style="text-indent: 30; margin-left: 6; margin-right: 6">');
  256.       HTMLText := Copy(HTMLText, BeginPos, Length(HTMLText));
  257.       EndPos := Pos('</p>', HTMLText);
  258.       MovieComments := Trim(Copy(HTMLText, 0, EndPos-1));
  259.       HTMLRemoveTags(MovieComments);
  260.       MovieComments:=Trim(StringReplace(MovieComments,'"','"'));
  261.       MovieComments:=Trim(StringReplace(MovieComments,'***','"'));
  262.       MovieComments:=Trim(StringReplace(MovieComments,#13#10#13#10,#13#10));
  263.       SetField(fieldComments, '╨σ÷σφτΦ  ─µεφα ╤ΦδⁿΓσ≡α φα ⌠Φδⁿ∞: '+MovieComments);
  264.     end;
  265.   // ╩α≡≥ΦφΩα
  266.   if CanSetPicture then
  267.      GetPicture(MoviePictureAddress);
  268.   // ╨στ≤δⁿ≥α≥√;
  269. end;
  270.  
  271. //==============================================================================
  272. //==============================================================================
  273. //==============================================================================
  274. begin
  275.   if CheckVersion(3,5,0) then
  276.   begin
  277.     MovieName := GetField(fieldTranslatedTitle);
  278.     if MovieName = '' then
  279.       MovieName := GetField(fieldOriginalTitle);
  280.     AnalyzePage();
  281.   end else
  282.     ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
  283. end.
  284.